package cn.minimelon.api.config;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInterceptor;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;

import java.util.Properties;

@Configuration
public class PageHelperConfig {
    @Bean
    public PageInterceptor pageInterceptor() {
        return new PageInterceptor();
    }

    @Bean
    public PageHelper pageHelper(@Inject("${pagehelper}") Properties props) {
        PageHelper pageHelper = new PageHelper();
        props.setProperty("reasonable", "true");
        props.setProperty("offsetAsPageNum", "true");
        props.setProperty("rowBoundsWithCount", "true");
        pageHelper.setProperties(props);
        return pageHelper;
    }
}
